/**
  ******************************************************************************
  * @file    user_freertos.c
  * @version V1.0.1.180115_Beta
  * @date    2018.01.15
  * @author  bigvan_tech
  * @brief   Source code for freertos applications.
  ******************************************************************************
  * @note
  *
  * E-mail：bigvan_tech@126.com
  * Change Logs:
  * ----------------------------------------------------------------
  * Date        Version                 Author         Description
  * --------    --------------------    -----------    -------------
  * 20180115    V1.0.1.180115_Beta     	bigvan_tech    Tested.
  *
  ******************************************************************************  
  */

/* Includes ------------------------------------------------------------------*/
#include "user_freertos.h"

/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
TaskHandle_t xTask0Handle = NULL;
TaskHandle_t xTask2Handle = NULL;

/* Private function prototypes -----------------------------------------------*/
void vTask0(void *pvParameters);
void vTask1(void *pvParameters);
void vTask2(void *pvParameters);

/* Exported functions --------------------------------------------------------*/
/**
  * @brief  Create tasks.
  * @param  None
  * @retval None
  */
void AppTaskCreate(void)
{
	/* Create Task1 at priority 3. */
	xTaskCreate(vTask1,
							"Task1",
							128,
							NULL,
							3,
							NULL);
}

/* Private functions ---------------------------------------------------------*/
/**
  * @brief  The implementation of Task0. 
  * @param  pvParameters: Task functions accept a parameter of type void*.
  * @retval None
  */
void vTask0(void *pvParameters)
{
	for ( ;; )
	{	
		/* Toggle LED0. */
		HAL_GPIO_TogglePin(LED0_GPIO_Port, LED0_Pin);

		/* Delete Task0. */
		vTaskDelete(xTask0Handle);
	}
}

/**
  * @brief  The implementation of Task1. 
  * @param  pvParameters: Task functions accept a parameter of type void*.
  * @retval None
  */
void vTask1(void *pvParameters)
{
	for ( ;; )
	{	
		/* Toggle LED1. */
		HAL_GPIO_TogglePin(LED1_GPIO_Port, LED1_Pin);
	
		/* Create Task0 at priority 2. */
		xTaskCreate(vTask0,
								"Task0",
								128,
								NULL,
								2,
								&xTask0Handle);
		
		/* Create task2 at priority 4. */
		xTaskCreate(vTask2,
								"Task2",
								128,
								NULL,
								4,
								&xTask2Handle);
		
		vTaskDelay(pdMS_TO_TICKS(500));
	}
}

/**
  * @brief  The implementation of Task2.  
  * @param  pvParameters: Task functions accept a parameter of type void*.
  * @retval None
  */
void vTask2(void *pvParameters)
{
	for ( ;; )
	{			
		/* Toggle LED2. */
		HAL_GPIO_TogglePin(LED2_GPIO_Port, LED2_Pin);
		
		/* Delete Task2. */
		vTaskDelete(xTask2Handle);
	}
}
/********************************END OF FILE***********************************/
